package com.blog4j.article.api;

import cn.dev33.satoken.annotation.SaIgnore;
import com.blog4j.article.entity.CommentEntity;
import com.blog4j.article.model.Comment;
import com.blog4j.article.service.CommentService;
import com.blog4j.article.vo.req.CommentReqVo;
import com.blog4j.common.model.Result;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 98k灬
 * @version v1.0.0
 * @Description : 功能描述
 * @Create on : 2024/7/28 20:55
 **/
@RestController
@RequestMapping("/api/comment")
@RequiredArgsConstructor
public class ApiCommentController {
    private final CommentService commentService;

    /**
     * 获取文章评论列表
     *
     * @param reqVo 请求信息
     * @return 评论列表
     */
    @SaIgnore
    @PostMapping("/commentList")
    public Result commentList(@RequestBody @Valid CommentReqVo reqVo) {
        PageInfo<Comment> pageInfo = commentService.commentList(reqVo);
        return Result.ok(pageInfo);
    }
}
